import React from "react";
import { User } from "types/user";
import { Ilist } from "types/list";
import "./list.scss";
interface IlistProps {
  users: User[];
  list: Ilist[];
}

export const List = (props: IlistProps) => {
  const { users, list } = props;
  return (
    <div className="list">
      <table>
        <thead>
          <tr>
            <th className="name">名称</th>
            <th className="principal">负责人</th>
          </tr>
        </thead>
        <tbody>
          {list.map((item: any) => {
            return (
              <tr key={item.id}>
                <td>{item.name}</td>
                <td>
                  {users.find((user: any) => {
                    return user.id === item.personId;
                  })?.name || "未知"}
                </td>
              </tr>
            );
          })}
        </tbody>
      </table>
    </div>
  );
};
